﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraEditors;
using System.Windows.Forms;
using DevExpress.XtraBars;

namespace Ahi.Base.Kontroller
{
    public class MenuDropDownButton : DropDownButton
    {
        public ContextMenuStrip ContextMenuStrip { get; set; }

        protected override void OnArrowClick()
        {
            MenuyuGoster();
            base.OnArrowClick();
        }

        protected override void OnClick(EventArgs e)
        {
            MenuyuGoster();
            base.OnArrowClick();
        }

        private void MenuyuGoster()
        {
            if (ContextMenuStrip != null)
            {
                foreach (ToolStripItem menuItem in ContextMenuStrip.Items)
                {
                    BarButtonItem item = new BarButtonItem();
                    //if (menuItem.Image != null)
                    //    item.Glyph = ResourceManager.GetScaledBitmap(menuItem.Image, 16, 16);
                    item.Tag = menuItem;
                    item.Caption = menuItem.Text;
                    item.Id = new Random((int)DateTime.Now.Ticks).Next(); //barManager.GetNewItemId();
                    item.Enabled = menuItem.Enabled;
                    item.ItemClick += menuItem.Click;

                    //this.ItemLinks.Add(item);
                    //barManager.Items.Add(item);
                    //Add(item);
                    this.
                }
            }
        }
    }
}
